package com.ruoyi.web.controller.emergencyplan;

import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.core.page.TableDataInfo;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.common.utils.pengjie.SnowflakeIdUtils;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.emergencyplan.domain.EpResourceExpertManage;
import com.ruoyi.emergencyplan.service.IEpResourceExpertManageService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.web.bind.annotation.*;

import javax.servlet.http.HttpServletResponse;
import java.util.List;

/**
 * 应急资源——专家管理Controller
 * 
 * @author hcc
 * @date 2023-12-17
 */
@RestController
@RequestMapping("/emergencyplan/expertManage")
public class EpResourceExpertManageController extends BaseController
{
    @Autowired
    private IEpResourceExpertManageService epResourceExpertManageService;

    /**
     * 查询应急资源——专家管理列表
     */
    @PreAuthorize("@ss.hasPermi('emergencyplan:expertManage:list')")
    @GetMapping("/list")
    public TableDataInfo list(EpResourceExpertManage epResourceExpertManage)
    {
        startPage();
        List<EpResourceExpertManage> list = epResourceExpertManageService.selectEpResourceExpertManageList(epResourceExpertManage);
        return getDataTable(list);
    }

    /**
     * 导出应急资源——专家管理列表
     */
    @PreAuthorize("@ss.hasPermi('emergencyplan:expertManage:export')")
    @Log(title = "应急资源——专家管理", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, EpResourceExpertManage epResourceExpertManage)
    {
        List<EpResourceExpertManage> list = epResourceExpertManageService.selectEpResourceExpertManageList(epResourceExpertManage);
        ExcelUtil<EpResourceExpertManage> util = new ExcelUtil<EpResourceExpertManage>(EpResourceExpertManage.class);
        util.exportExcel(response, list, "应急资源——专家管理数据");
    }

    /**
     * 获取应急资源——专家管理详细信息
     */
    @PreAuthorize("@ss.hasPermi('emergencyplan:expertManage:query')")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") String id)
    {
        return success(epResourceExpertManageService.selectEpResourceExpertManageById(id));
    }

    /**
     * 新增应急资源——专家管理
     */
    @PreAuthorize("@ss.hasPermi('emergencyplan:expertManage:add')")
    @Log(title = "应急资源——专家管理", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody EpResourceExpertManage epResourceExpertManage)
    {
        epResourceExpertManage.setId(String.valueOf(new SnowflakeIdUtils(5,8).nextId()));
        return toAjax(epResourceExpertManageService.insertEpResourceExpertManage(epResourceExpertManage));
    }

    /**
     * 修改应急资源——专家管理
     */
    @PreAuthorize("@ss.hasPermi('emergencyplan:expertManage:edit')")
    @Log(title = "应急资源——专家管理", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody EpResourceExpertManage epResourceExpertManage)
    {
        return toAjax(epResourceExpertManageService.updateEpResourceExpertManage(epResourceExpertManage));
    }

    /**
     * 删除应急资源——专家管理
     */
    @PreAuthorize("@ss.hasPermi('emergencyplan:expertManage:remove')")
    @Log(title = "应急资源——专家管理", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable String[] ids)
    {
        return toAjax(epResourceExpertManageService.deleteEpResourceExpertManageByIds(ids));
    }
}
